using System;
using System.Collections.Generic;
using System.Text;
using FlatRedBall;
using FlatRedBall.Input;
using FlatRedBall.AI.Pathfinding;
using FlatRedBall.Graphics.Animation;
using FlatRedBall.Graphics.Particle;

using FlatRedBall.Math.Geometry;
using FlatRedBall.Math.Splines;
using BitmapFont = FlatRedBall.Graphics.BitmapFont;
using Cursor = FlatRedBall.Gui.Cursor;
using GuiManager = FlatRedBall.Gui.GuiManager;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

#if FRB_XNA || SILVERLIGHT
using Keys = Microsoft.Xna.Framework.Input.Keys;
using Vector3 = Microsoft.Xna.Framework.Vector3;
using Texture2D = Microsoft.Xna.Framework.Graphics.Texture2D;


#endif

namespace Gnome.Entities
{
	public partial class Obstacle
	{

        Sprite overlayeffect;
        bool hasoverlay = false;

        public Sprite OverlayEffect
        {
            get { return overlayeffect; }
        }

        public bool HasOverlay
        {
            get { return hasoverlay; }
        }

		private void CustomInitialize()
		{
            //this.Collision = new AxisAlignedRectangle();
            Vector3 position = new Vector3(this.X,this.Y,this.Z);
            this.Position = position;
            this.Collision.Position = position;
		}

		private void CustomActivity()
		{


		}

		private void CustomDestroy()
		{


		}

        public void setupSprite(Sprite inputsprite)
        {
            Position = inputsprite.Position;
            VisRep = inputsprite;
            VisRep.AttachTo(this, false);
            Z = 1;
            if (inputsprite.Texture.ToString().Contains("big_puddle"))
            {
                Collision.ScaleX = VisRep.ScaleX / 1.3f;
                Collision.ScaleY = VisRep.ScaleY / 1.3f;
            }
            else if (inputsprite.Texture.ToString().Contains("grass"))
            {
                Collision.ScaleX = VisRep.ScaleX / 1.5f;
                Collision.ScaleY = VisRep.ScaleY / 1.5f;
                Texture2D mid = FlatRedBallServices.Load<Texture2D>(@"Content/Screens/LevelOne/Images/tallgrass2.png");
                Texture2D left = FlatRedBallServices.Load<Texture2D>(@"Content/Screens/LevelOne/Images/tallgrassleft.png");
                Texture2D right = FlatRedBallServices.Load<Texture2D>(@"Content/Screens/LevelOne/Images/tallgrassright.png");
                AnimationChain stillframe = new AnimationChain(1);
                stillframe.Add(new AnimationFrame(mid, 0.3f));
                VisRep.AnimationChains.Add(stillframe);
                AnimationChain rustling = new AnimationChain(4);
                rustling.Add(new AnimationFrame(mid, 0.1f));
                rustling.Add(new AnimationFrame(left, 0.1f));
                rustling.Add(new AnimationFrame(mid, 0.1f));
                rustling.Add(new AnimationFrame(right, 0.1f));
                VisRep.AnimationChains.Add(rustling);
                VisRep.Texture = mid;
                VisRep.ScaleX = inputsprite.ScaleX * 1.3f;
                VisRep.ScaleY = inputsprite.ScaleY * 1.3f;

                //Set up grass rustling effect
                overlayeffect = new Sprite();
                overlayeffect.AnimationChains = GrassRustleScene.Sprites[0].AnimationChains;
                overlayeffect.CurrentChainIndex = 0;
                overlayeffect.ScaleX = VisRep.ScaleX;
                overlayeffect.ScaleY = VisRep.ScaleY*.7f;
                overlayeffect.Animate = true;
                SpriteManager.AddSprite(overlayeffect);
                overlayeffect.AttachTo(this, false);
                overlayeffect.RelativeY -= VisRep.ScaleY *.3f;
                overlayeffect.Visible = false;
                hasoverlay = true;
            }
            else
            {
                Collision.ScaleX = VisRep.ScaleX;
                Collision.ScaleY = VisRep.ScaleY / 1.3f;
            }
        }

        private static void CustomLoadStaticContent(string contentManagerName)
        {


        }
	}
}
